//
// Created by Administrator on 2021/11/25.
//

#include "Display.h"

Display *Display::currentInstance = nullptr;

Display::Display(RayCasting *r, int argc, char **argv) {
    this->r = r;

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(200, 200);
    glutCreateWindow("Ray-Casting");
    // 背景设为白色
    glClearColor(1, 1, 1, 1);
}

void Display::exec() {
    setup_display_callback();
    glutMainLoop();
}

void Display::display() {
    glClear(GL_COLOR_BUFFER_BIT);
    glDrawPixels(400, 500, GL_RGBA, GL_FLOAT, r->get_rgba());  //使用OpenGL的绘图函数
    glFlush();
}
